<?php
/**
 * Date: 2024.8
 * Author: kahn
 * 管理请求传入数据
 */
namespace config;

/*
 * 公共参数
 */
class Common{
    private static array $data;

    public static function setData(array $data): void
    {
        self::$data = $data;
    }

    public static function getData(): array
    {
        return self::$data;
    }

    /**
     * @param $method
     * @param $arg
     * @return mixed
     */
    public function __get($key): mixed
    {
        if(isset(self::$data[$key])){
            return self::$data[$key];
        }elseif(isset(self::$data['common'][$key])){
            return self::$data['common'][$key];
        }else{
            return null;
        }
    }

    public static function getRule(): array
    {
        return [
            'common.platform' => 'require|platform',
            'common.device' => 'require|device',
            'common.os' => 'require|os',
            'common.version' => 'require|version',
            'common.ts'  => 'require|timestamp',
        ];
    }


}